const http = require('./http_client');
const fs = require('fs');

async function openFile(uri) {
    if (uri.indexOf('https') != -1) {
        let ret = await http.httpsGet(uri);
        return ret.body.toString();
    } else if (uri.indexOf('http') != -1) {
        let ret = await http.httpGet(uri);
        return ret.body.toString();
    } else {
        return fs.readFileSync(uri).toString();
    }
}

module.exports = openFile;
